package ws.very.util.dingtalk.api

import com.dingtalk.open.client.ServiceFactory
import com.dingtalk.open.client.api.service.corp.CorpDepartmentService

import scala.concurrent.{ExecutionContext, Future}

private[dingtalk] object DepartmentServiceHelper {
  val serviceFactory = ServiceFactory.getInstance
  val departmentService = serviceFactory.getOpenService(classOf[CorpDepartmentService])


  def createDepartment(accessToken: S, name: S, parentId: S, order: S, createDeptGroup: B)(implicit executor: ExecutionContext) = Future {
    departmentService.deptCreate(accessToken, name, parentId, order, createDeptGroup)
  }

  def getDeptList(accessToken: S, parentDeptId: Option[S])(implicit executor: ExecutionContext) = Future {
    departmentService.getDeptList(accessToken, parentDeptId.getOrElse(null))
  }
}
